package com.test.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class DateAdapter extends XmlAdapter<String, Date> {

	private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	
	public Date unmarshal(String dateStr) throws ParseException {
		return dateFormat.parse(dateStr);
	}

	public String marshal(Date date) {
		String result = null;
		if(date != null) {
			result = dateFormat.format(date);
		}
		
		return result;
	}

}
